package com.tdkj.action.backstage.risevalue;

import java.math.BigDecimal;
import java.util.List;

import javax.annotation.Resource;

import com.tdkj.action.BaseAction;
import com.tdkj.model.risevalue.BeanPlateSMSCustom;
import com.tdkj.service.risevalue.IBeanPlateSMSCustomService;


public class PlateSMSCustomAction extends BaseAction {
    
	private IBeanPlateSMSCustomService plateSMSCustomService;
	
	private Long plateId;
	
	private Long id;
	
	private BigDecimal timeLimitAmount;
	
	private String timeLimitUnit;
	
	private BigDecimal price;
	
	private String unit;
	
	private List<BeanPlateSMSCustom> customs ;
	
	private BeanPlateSMSCustom custom ;
	
	private String message;
	
	public String add() {
		plateSMSCustomService.add(timeLimitAmount, timeLimitUnit, price, unit, plateId);
		this.setMessage("添加成功");
		return getByPlateId();
	}
	
	public String update() {
		plateSMSCustomService.update(id, timeLimitAmount, timeLimitUnit, price, unit);
		plateId = plateSMSCustomService.get(id).getPlate().getId();
		this.setMessage("保存成功");
		return getByPlateId();
	}

	public String del() {
		plateSMSCustomService.delete(id);
		this.setMessage("删除成功");
		return "delete";
	}
	
	public String edit() {
		custom = plateSMSCustomService.get(id);
		this.setMessage("获取成功");
		return "edit";
	}
	
	public String get() {
		custom = plateSMSCustomService.get(id);
		this.setMessage("获取成功");
		return "get";
	}
	
	public String getByPlateId() {
		customs = plateSMSCustomService.getByPlateId(plateId);
		this.setMessage("获取成功");
		return "getByPlateId";
	}
	
	public String execute() {
		customs = plateSMSCustomService.getAll();
		return "success";
	}
	

	@Resource
	public void setPlateSMSCustomService(IBeanPlateSMSCustomService plateSMSCustomService) {
		this.plateSMSCustomService = plateSMSCustomService;
	}

	/**
	 * @return the plateId
	 */
	public long getPlateId() {
		return plateId;
	}

	/**
	 * @param plateId the plateId to set
	 */
	public void setPlateId(Long plateId) {
		this.plateId = plateId;
	}

	/**
	 * @return the id
	 */
	public long getId() {
		return id;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return the timeLimitAmount
	 */
	public BigDecimal getTimeLimitAmount() {
		return timeLimitAmount;
	}

	/**
	 * @param timeLimitAmount the timeLimitAmount to set
	 */
	public void setTimeLimitAmount(BigDecimal timeLimitAmount) {
		this.timeLimitAmount = timeLimitAmount;
	}

	/**
	 * @return the timeLimitUnit
	 */
	public String getTimeLimitUnit() {
		return timeLimitUnit;
	}

	/**
	 * @param timeLimitUnit the timeLimitUnit to set
	 */
	public void setTimeLimitUnit(String timeLimitUnit) {
		this.timeLimitUnit = timeLimitUnit;
	}

	/**
	 * @return the price
	 */
	public BigDecimal getPrice() {
		return price;
	}

	/**
	 * @param price the price to set
	 */
	public void setPrice(BigDecimal price) {
		this.price = price;
	}

	/**
	 * @return the unit
	 */
	public String getUnit() {
		return unit;
	}

	/**
	 * @param unit the unit to set
	 */
	public void setUnit(String unit) {
		this.unit = unit;
	}

	/**
	 * @return the customs
	 */
	public List<BeanPlateSMSCustom> getCustoms() {
		return customs;
	}

	/**
	 * @param customs the customs to set
	 */
	public void setCustoms(List<BeanPlateSMSCustom> customs) {
		this.customs = customs;
	}

	/**
	 * @return the custom
	 */
	public BeanPlateSMSCustom getCustom() {
		return custom;
	}

	/**
	 * @param custom the custom to set
	 */
	public void setCustom(BeanPlateSMSCustom custom) {
		this.custom = custom;
	}

	/**
	 * @return the message
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * @param message the message to set
	 */
	public void setMessage(String message) {
		this.message = message;
	}
	
}
